import { ApiProperty } from '@nestjs/swagger';
import {
  IsOptional,
  IsString,
  IsNotEmpty,
  MaxLength,
  MinLength,
  IsEmail,
} from 'class-validator';

export class UpdateUserDto {
  @ApiProperty({
    description: '用户昵称',
    example: 'vieNow_60y',
    required: false,
  })
  @IsOptional()
  @IsString()
  @IsNotEmpty()
  @MinLength(1)
  @MaxLength(20)
  nickname?: string;

  @ApiProperty({
    description: '用户头像URL',
    example: 'https://example.com/avatar.jpg',
    required: false,
  })
  @IsOptional()
  @IsString()
  avatar?: string;


  @ApiProperty({
    description: '用户邮箱',
    example: 'example@example.com',
    required: false,
  })
  @IsOptional()
  @IsEmail()
  email?: string;

  @ApiProperty({
    description: '个人简介',
    example: '这是我的个人简介',
    required: false,
  })
  @IsOptional()
  @IsString()
  @MaxLength(200)
  bio?: string;

  @ApiProperty({
    description: '微信号',
    example: 'wechat123',
    required: false,
  })
  @IsOptional()
  @IsString()
  wechat?: string;

  @ApiProperty({
    description: 'QQ号',
    example: '123456789',
    required: false,
  })
  @IsOptional()
  @IsString()
  qq?: string;
}

export class UserProfileResponseDto {
  @ApiProperty({ description: '用户ID' })
  id: number;

  @ApiProperty({ description: '用户昵称' })
  nickname: string;

  @ApiProperty({ description: '用户头像', required: false })
  avatar?: string;

  @ApiProperty({ description: '邮箱', required: false })
  email?: string;

  @ApiProperty({ description: '手机号', required: false })
  phone?: string;

  @ApiProperty({ description: '个人简介', required: false })
  bio?: string;

  @ApiProperty({ description: '微信号', required: false })
  wechat?: string;

  @ApiProperty({ description: 'QQ号', required: false })
  qq?: string;

  @ApiProperty({ description: '积分点数' })
  points: number;

  @ApiProperty({ description: '学习时长（分钟）' })
  studyTime: number;

  @ApiProperty({ description: '短剧节数' })
  shortsCount: number;

  @ApiProperty({ description: '创建时间' })
  createdAt: string;

  @ApiProperty({ description: '更新时间' })
  updatedAt: string;
}

// 添加用户密码更新DTO
export class UpdatePasswordDto {
  @ApiProperty({ description: '当前密码' })
  @IsString()
  @IsNotEmpty()
  currentPassword: string;

  @ApiProperty({ description: '新密码' })
  @IsString()
  @IsNotEmpty()
  @MinLength(6)
  @MaxLength(20)
  newPassword: string;
}

// 添加用户邮箱更新DTO
export class UpdateEmailDto {
  @ApiProperty({ description: '新邮箱地址' })
  @IsEmail()
  @IsNotEmpty()
  email: string;

  @ApiProperty({ description: '验证码' })
  @IsString()
  @IsNotEmpty()
  verificationCode: string;
}

// 添加文件上传响应DTO
export class FileUploadResponseDto {
  @ApiProperty({ description: '文件访问URL' })
  url: string;

  @ApiProperty({ description: '文件位置（兼容wangEditor）' })
  location: string;

  @ApiProperty({ description: '生成的文件名' })
  filename: string;

  @ApiProperty({ description: '原始文件名' })
  originalName: string;

  @ApiProperty({ description: '文件大小（字节）' })
  size: number;

  @ApiProperty({ description: '文件类型' })
  type: string;

  @ApiProperty({ description: '存储信息' })
  storage: {
    bucket: string;
    region: string;
    key: string;
    path: string;
  };
}

// 添加上传配置响应DTO
export class UploadConfigResponseDto {
  @ApiProperty({ description: '最大图片大小（字节）' })
  maxImageSize: number;

  @ApiProperty({ description: '最大视频大小（字节）' })
  maxVideoSize: number;

  @ApiProperty({ description: '最大音频大小（字节）' })
  maxAudioSize: number;

  @ApiProperty({ description: '允许的图片类型' })
  allowedImageTypes: string[];

  @ApiProperty({ description: '允许的视频类型' })
  allowedVideoTypes: string[];

  @ApiProperty({ description: '允许的音频类型' })
  allowedAudioTypes: string[];

  @ApiProperty({ description: '上传路径' })
  uploadPath: string;

  @ApiProperty({ description: 'COS配置状态' })
  cosConfig: {
    hasSecretId: boolean;
    hasSecretKey: boolean;
    hasBucket: boolean;
    hasRegion: boolean;
    bucket?: string;
    region?: string;
  };
}
